/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.be;

import java.io.Serializable;
import javax.faces.model.SelectItem;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.myfaces.custom.fileupload.UploadedFile;

/**
 *
 * @author FreddyHIQ
 */
@Entity
@Table(name = "tra_doc_requerido")
@NamedQueries({@NamedQuery(name = "DocRequerido.findAll", query = "SELECT d FROM DocRequerido d"), @NamedQuery(name = "DocRequerido.findByDreCodigo", query = "SELECT d FROM DocRequerido d WHERE d.dreCodigo = :dreCodigo"), @NamedQuery(name = "DocRequerido.findByDreLectura", query = "SELECT d FROM DocRequerido d WHERE d.dreLectura = :dreLectura")})
public class DocRequerido implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "dre_codigo")
    private Long dreCodigo;
    @Basic(optional = false)
    @Column(name = "dre_lectura")
    private boolean dreLectura;
    @Transient
    private UploadedFile upFile;
    @Transient
    private int codigo;
    @Transient
    private String glosa;
    @Transient    
    private boolean estado;
    @Transient
    private SelectItem[] cuentaIngresoT;
    @Transient
    private CuentaingresoTramite ciTramite;
    @JoinColumn(name = "fk_pro_codigo", referencedColumnName = "pro_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Procedimiento fkProCodigo;
    @JoinColumn(name = "fk_tdo_codigo", referencedColumnName = "tdo_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoDocumento fkTdoCodigo;

    public DocRequerido() {
    }

    public DocRequerido(Long dreCodigo) {
        this.dreCodigo = dreCodigo;
    }

    public DocRequerido(Long dreCodigo, TipoDocumento nombre, UploadedFile file, String glosa, int codigo) {
        this.dreCodigo = dreCodigo;
        this.fkTdoCodigo = nombre;
        this.upFile = file;        
        this.glosa = glosa;
        this.codigo = codigo;
    }

    public DocRequerido(Long dreCodigo, boolean dreLectura) {
        this.dreCodigo = dreCodigo;
        this.dreLectura = dreLectura;
    }

    public DocRequerido(TipoDocumento tDoc) {
        this.fkTdoCodigo=tDoc;
    }

    public DocRequerido(Procedimiento proc, TipoDocumento tDoc, boolean dreLectura) {
        this.fkProCodigo=proc;
        this.fkTdoCodigo=tDoc;
        this.dreLectura = dreLectura;        
    }

    public Long getDreCodigo() {
        return dreCodigo;
    }

    public void setDreCodigo(Long dreCodigo) {
        this.dreCodigo = dreCodigo;
    }

    public boolean getDreLectura() {
        return dreLectura;
    }

    public void setDreLectura(boolean dreLectura) {
        this.dreLectura = dreLectura;
    }

    public Procedimiento getFkProCodigo() {
        return fkProCodigo;
    }

    public void setFkProCodigo(Procedimiento fkProCodigo) {
        this.fkProCodigo = fkProCodigo;
    }

    public TipoDocumento getFkTdoCodigo() {
        return fkTdoCodigo;
    }

    public void setFkTdoCodigo(TipoDocumento fkTdoCodigo) {
        this.fkTdoCodigo = fkTdoCodigo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dreCodigo != null ? dreCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DocRequerido)) {
            return false;
        }
        DocRequerido other = (DocRequerido) object;
        if ((this.dreCodigo == null && other.dreCodigo != null) || (this.dreCodigo != null && !this.dreCodigo.equals(other.dreCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.tramite.be.DocRequerido[dreCodigo=" + dreCodigo + "]";
    }

    public UploadedFile getUpFile() {
        return upFile;
    }

    public void setUpFile(UploadedFile upFile) {
        this.upFile = upFile;
    }

    public int getCodigo() {
        return codigo;
    }

    public void setCodigo(int codigo) {
        this.codigo = codigo;
    }

    public String getGlosa() {
        return glosa;
    }

    public void setGlosa(String glosa) {
        this.glosa = glosa;
    }

    public boolean isEstado() {
        return estado;
    }

    public void setEstado(boolean estado) {
        this.estado = estado;
    }

    public SelectItem[] getCuentaIngresoT() {
        return cuentaIngresoT;
    }

    public void setCuentaIngresoT(SelectItem[] cuentaIngresoT) {
        this.cuentaIngresoT = cuentaIngresoT;
    }

    public CuentaingresoTramite getCiTramite() {
        return ciTramite;
    }

    public void setCiTramite(CuentaingresoTramite ciTramite) {
        this.ciTramite = ciTramite;
    }
}